<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html class="no-js">
<jsp:include page="../common/common-head.jsp"/>
<body>
<!-- Main wrapper -->
<div class="wrapper" id="wrapper">
  <!-- Header -->
  <jsp:include page="../common/common-top.jsp"/>

  <!-- //Header -->

  <!-- Start Bradcaump area -->
  <div class="ht__bradcaump__area bg-image--3">
    <div class="container">
      <div class="row">
        <div class="col-lg-12">
          <div class="bradcaump__inner text-center">
            <h2 class="bradcaump-title">我的订单</h2>
            <nav class="bradcaump-content">
              <a class="breadcrumb_item" href="/">Home</a>
              <span class="brd-separetor">/</span>
              <span class="breadcrumb_item active">我的订单</span>
            </nav>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- End Bradcaump area -->


  <!-- Start Shop Page -->
  <div class="cart-main-area section-padding--lg bg--white">
    <div class="container">
      <div class="row">
        <div class="col-md-12 col-sm-12 ol-lg-12">
          <form action="#">
            <div class="table-content wnro__table table-responsive">
              <table>
                <thead>
                <tr class="title-top">
                  <th>订单信息</th>
                  <th class="product-price">总价</th>
                  <th>明细</th>
                  <th>评价</th>
                  <th>状态</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${pageInfo.list}" var="item">
                  <tr>
                    <td>
                      联系电话：${item.phone}<br/>
                      备注：${item.remark}<br/>
                      下单时间：<fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                    </td>
                    <td class="product-price"><span class="amount">$${item.money}元</span></td>
                    <td>
                      <table>
                        <thead>
                        <tr class="title-top">
                          <th class="product-thumbnail">图书</th>
                          <th class="product-name">数量</th>
                          <th class="product-price">总价</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${item.itemList}" var="node">
                          <tr>
                            <td>${node.goodsName}</td>
                            <td>${node.num}</td>
                            <td class="product-price"><span class="amount">$${node.num*node.goodsMoney}元</span></td>
                          </tr>
                        </c:forEach>

                        </tbody>
                      </table>
                    </td>
                    <td>
                      <c:if test="${empty item.comment}">
                        <a href="#" onclick="pinjia('${item.id}')">评价</a>
                      </c:if>
                      <c:if test="${not empty item.comment}">
                        ${item.comment}
                      </c:if>

                    </td>
                    <td>${item.status}</td>
                    <td class="product-remove">
                      <c:if test="${item.status == '待发货'}">
                        <a href="/orders/cancel/${item.id}">取消</a>
                      </c:if>
                    </td>
                  </tr>
                </c:forEach>

                </tbody>
              </table>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
  <!-- End Shop Page -->
  <!-- Footer Area -->
  <jsp:include page="../common/common-footer.jsp"/>
  <!-- //Footer Area -->
</div>
<!-- //Main wrapper -->


<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="exampleModalLabel">评价订单</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
            aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body">
        <form method="post" action="/orders/comment" id="form">
          <input type="hidden" name="id" value="" id="id">
          <div class="form-group">
            <label class="control-label">评论:</label>
            <textarea class="form-control" name="comment"></textarea>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary" form="form">发表评论</button>
      </div>
    </div>
  </div>
</div>


<jsp:include page="../common/common-script.jsp"/>
<script>
  function pinjia(id) {
    $("#id").val(id)
    $("#exampleModal").modal("show");
  }
</script>
</body>
</html>
